package com.jinzhi.jzweb.controller.backstage;

import com.baomidou.mybatisplus.plugins.Page;
import com.jinzhi.common.annotation.Log;
import com.jinzhi.common.base.BaseController;
import com.jinzhi.common.utils.Result;
import com.jinzhi.jzweb.domain.JazUserAuntDO;
import com.jinzhi.jzweb.domain.JazUserHouseDO;
import com.jinzhi.jzweb.domain.param.UserHouseQuery;
import com.jinzhi.jzweb.domain.vo.JazUserHouseVO;
import com.jinzhi.jzweb.domain.vo.userAunt.UserAuntVO;
import com.jinzhi.jzweb.service.JazUserAuntService;
import com.jinzhi.jzweb.service.JazUserHouseService;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/***
 * @author ChangPanYuan
 * @Date 2024/5/10
 * @Description: 用户住宿控制层
 * @Version 1.0
 */
@Controller
@RequestMapping("/userHouse")
@Api(value = "住宿管理", tags = "住宿管理")
public class UserHouseController extends BaseController {

    @Autowired
    private JazUserHouseService jazUserHouseService;

    /**
     * 分页查询住宿列表
     * @param userHouseQuery
     * @return
     */
    @ResponseBody
    @PostMapping(value = "/getUserHousePage")
    @RequiresPermissions("jzweb:jazUserAuntStay:list")
    public Result<Page<JazUserHouseDO>> getUserAuntPage(@RequestBody UserHouseQuery userHouseQuery){
        return Result.ok(jazUserHouseService.getUserHousePage(userHouseQuery));
    }

    /**
     * 新增住宿
     * @param userHouseDO
     * @return
     */
    @Log(value = "新增住宿",sysModule = 2,operationType = 1)
    @ResponseBody
    @PostMapping("/insertHouse")
    public Result<String> insertAunt(@RequestBody JazUserHouseDO userHouseDO){
        return jazUserHouseService.insertUserHouse(userHouseDO);
    }

    @ApiOperation(value = "根据id删除住宿信息", notes = "根据id删除住宿信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "id"),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @Log(value = "删除住宿",sysModule = 2,operationType = 2)
    @PostMapping(value = "/deletedById")
    public Result<Object> deletedByUserId(@RequestParam("id") Long id){
        return jazUserHouseService.deletedById(id);
    }

    @ApiOperation(value = "根据id查询详细信息", notes = "根据id查询详细信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long"),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @GetMapping(value = "/getUserHouseById")
    public Result<JazUserHouseDO> getUserAuntById(@RequestParam("id") Long id){
        return Result.ok(jazUserHouseService.getUserHouseById(id));
    }

    @ApiOperation(value = "修改审核住宿信息", notes = "修改审核住宿信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "JazUserHouseDO", value = "JazUserHouseDO", required = true, dataType = "JazUserHouseDO"),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @Log(value = "修改审核住宿信息",sysModule = 2,operationType = 3)
    @ResponseBody
    @PostMapping(value = "/updateExamineHouse")
    public Result updateExamineHouse(@RequestBody JazUserHouseDO jazUserHouseDO){
        return jazUserHouseService.updateExamineHouse(jazUserHouseDO);
    }

    @Log(value = "修改住宿信息",sysModule = 2,operationType = 3)
    @ApiOperation(value = "修改住宿信息", notes = "修改住宿信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "JazUserHouseDO", value = "JazUserHouseDO", required = true, dataType = "JazUserHouseDO"),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @PostMapping(value = "/updateHouse")
    public Result updateHouse(@RequestBody JazUserHouseDO jazUserHouseDO) {
        return jazUserHouseService.updateHouse(jazUserHouseDO);
    }
//
//    @ApiOperation(value = "住宿列表页面入口", notes = "住宿嫂列表页面入口")
//    @ApiImplicitParams({
//    })
//    @GetMapping()
//    @RequiresPermissions("jzweb:jazUserHouse:jazUserHouse")
//    public String JazUserHouse(){
//        return "jzweb/jazUserHouse/jazUserHouse";
//    }

//    @ApiOperation(value = "新增住宿页面入口", notes = "新增住宿页面入口")
//    @ApiImplicitParams({
//    })
//    @GetMapping("/add")
//    @RequiresPermissions("jzweb:jazUserHouse:add")
//    public String add(){
//        return "jzweb/jazUserHouse/add";
//    }


    @ApiOperation(value = "修改住宿页面入口", notes = "修改住宿页面入口")
    @ApiImplicitParams({
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @GetMapping(value = "/edit")
    @RequiresPermissions("jzweb:jazUserHouse:edit")
    public String edit(){
        return "jzweb/jazUserHouse/edit";
    }

    @ApiOperation(value = "住宿详情页面入口", notes = "住宿详情页面入口")
    @ApiImplicitParams({
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @GetMapping("/info")
    @RequiresPermissions("jzweb:jazUserHouse:info")
    public String info(){
        return "jzweb/jazUserHouse/info";
    }


}
